package com.itheima.app.interceptor;

import com.itheima.domain.db.User;

/**
 * 操作user的线程绑定
 */
public class UserHolder {
    private static ThreadLocal<User> local = new ThreadLocal<>();

    /**
     * 放入线程
     */
    public static void set(User user) {
        local.set(user);
    }

    /**
     * 获取
     */
    public static User get() {
        return local.get();
    }

    /**
     * 移除
     */
    public static void remove() {
        local.remove();
    }

    /**
     * 获取id
     */
    public static Long getId() {
        return get().getId();

    }
}
